home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Text⁄Files / Dialectic 1.1 Source / Dialectic ƒ / Raw dialects ƒ / chef.c next >
Encoding:
C/C++ Source or Header  |  1994-02-14  |  4.2 KB  |  224 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        chef.c
  4.  
  5. Purpose:    This module handles actually converting text into Chef talk.
  6.  
  7.  
  8. Dialectic -=- dialect text conversion extraordinare
  9. Copyright ©1994, Mark Pilgrim
  10.  
  11. This program is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 2 of the License, or
  14. (at your option) any later version.
  15.  
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. GNU General Public License for more details.
  20.  
  21. You should have received a copy of the GNU General Public License
  22. along with this program in a file named "GNU General Public License".
  23. If not, write to the Free Software Foundation, 675 Mass Ave,
  24. Cambridge, MA 02139, USA.
  25.  
  26. \**********************************************************************/
  27.  
  28. #include "dialectic dispatch.h"
  29. #include "dialectic utilities.h"
  30. #include "program globals.h"
  31.  
  32. void ConvertChef(void)
  33. {
  34.     char            oneChar;
  35.     
  36.     oneChar=(ThisChar())|0x20;
  37.     
  38.     if ((ThisChar()=='.') && (NextChar(1)==0x0d))
  39.     {
  40.         gInWord=gSeenI=FALSE;
  41.         StoreChar('.');
  42.         StoreChar(0x0d);
  43.         StoreString("\pBork Bork Bork!");
  44.         InputPlus(1);
  45.         return;
  46.     }
  47.     
  48.     if (!IsAlpha(ThisChar()))
  49.     {
  50.         gInWord=gSeenI=FALSE;
  51.         StoreChar(ThisChar());
  52.         InputPlus(1);
  53.         return;
  54.     }
  55.     
  56.     if ((!gInWord) && (oneChar=='b') && (NextChar(1)=='o')
  57.             && (NextChar(2)=='r') && (NextChar(3)=='k'))
  58.     {
  59.         gInWord=TRUE;
  60.         StoreChar(ThisChar());
  61.         StoreString("\pork");
  62.         InputPlus(4);
  63.         return;
  64.     }
  65.     
  66.     if ((oneChar=='a') && (NextChar(1)=='n'))
  67.     {
  68.         gInWord=TRUE;
  69.         StoreChar(ThisChar()+'u'-'a');
  70.         StoreChar('n');
  71.         InputPlus(2);
  72.         return;
  73.     }
  74.     
  75.     if ((oneChar=='a') && (NextChar(1)=='u'))
  76.     {
  77.         gInWord=TRUE;
  78.         StoreChar(ThisChar()+'o'-'a');
  79.         StoreChar('o');
  80.         InputPlus(2);
  81.         return;
  82.     }
  83.     
  84.     if ((oneChar=='a') && (IsAlpha(NextChar(1))))
  85.     {
  86.         gInWord=TRUE;
  87.         StoreChar(ThisChar()+'e'-'a');
  88.         InputPlus(1);
  89.         return;
  90.     }
  91.     
  92.     if ((ThisChar()=='e') && (NextChar(1)=='n') && (!IsAlpha(NextChar(2))))
  93.     {
  94.         gInWord=TRUE;
  95.         StoreString("\pee");
  96.         InputPlus(2);
  97.         return;
  98.     }
  99.     
  100.     if ((gInWord) && (ThisChar()=='e') && (NextChar(1)=='w'))
  101.     {
  102.         StoreString("\poo");
  103.         InputPlus(2);
  104.         return;
  105.     }
  106.     
  107.     if ((gInWord) && (ThisChar()=='e') && (!IsAlpha(NextChar(1))))
  108.     {
  109.         StoreString("\pe-a");
  110.         InputPlus(1);
  111.         return;
  112.     }
  113.     
  114.     if ((!gInWord) && (oneChar=='e'))
  115.     {
  116.         gInWord=TRUE;
  117.         StoreChar(ThisChar()+'i'-'e');
  118.         InputPlus(1);
  119.         return;
  120.     }
  121.     
  122.     if ((gInWord) && (ThisChar()=='f'))
  123.     {
  124.         StoreString("\pff");
  125.         InputPlus(1);
  126.         return;
  127.     }
  128.     
  129.     if ((gInWord) && (ThisChar()=='i') && (NextChar(1)=='r'))
  130.     {
  131.         StoreString("\pur");
  132.         InputPlus(2);
  133.         return;
  134.     }
  135.     
  136.     if ((gInWord) && (ThisChar()=='i'))
  137.     {
  138.         if (gSeenI)
  139.             StoreChar('i');
  140.         else
  141.             StoreString("\pee");
  142.         gSeenI=TRUE;
  143.         InputPlus(1);
  144.         return;
  145.     }
  146.     
  147.     if ((gInWord) && (ThisChar()=='o') && (NextChar(1)=='w'))
  148.     {
  149.         StoreString("\poo");
  150.         InputPlus(2);
  151.         return;
  152.     }
  153.     
  154.     if ((!gInWord) && (oneChar=='o'))
  155.     {
  156.         gInWord=TRUE;
  157.         StoreChar(ThisChar());
  158.         StoreChar(((oneChar=='O') && (IsUpperAlpha(NextChar(1)))) ? 'O' : 'o');
  159.         InputPlus(1);
  160.         return;
  161.     }
  162.     
  163.     if ((gInWord) && (ThisChar()=='o'))
  164.     {
  165.         StoreChar('u');
  166.         InputPlus(1);
  167.         return;
  168.     }
  169.     
  170.     if ((oneChar=='t') && (NextChar(1)=='h') && (NextChar(2)=='e'))
  171.     {
  172.         gInWord=TRUE;
  173.         StoreChar(ThisChar()+'z'-'t');
  174.         StoreString("\pee");
  175.         InputPlus(3);
  176.         return;
  177.     }
  178.     
  179.     if ((ThisChar()=='t') && (NextChar(1)=='h') && (!IsAlpha(NextChar(2))))
  180.     {
  181.         gInWord=TRUE;
  182.         StoreChar('t');
  183.         InputPlus(2);
  184.         return;
  185.     }
  186.     
  187.     if ((gInWord) && (ThisChar()=='t') && (NextChar(1)=='i') && (NextChar(2)=='o') && (NextChar(3)=='n'))
  188.     {
  189.         gInWord=TRUE;
  190.         StoreString("\pshun");
  191.         InputPlus(4);
  192.         return;
  193.     }
  194.     
  195.     if ((gInWord) && (oneChar=='u'))
  196.     {
  197.         gInWord=TRUE;
  198.         StoreChar(ThisChar()+'o'-'u');
  199.         StoreChar((IsUpperAlpha(NextChar(1))) ? 'O' : 'o');
  200.         InputPlus(1);
  201.         return;
  202.     }
  203.     
  204.     if (oneChar=='v')
  205.     {
  206.         gInWord=TRUE;
  207.         StoreChar(ThisChar()+'f'-'v');
  208.         InputPlus(1);
  209.         return;
  210.     }
  211.     
  212.     if (oneChar=='w')
  213.     {
  214.         gInWord=TRUE;
  215.         StoreChar(ThisChar()+'v'-'w');
  216.         InputPlus(1);
  217.         return;
  218.     }
  219.     
  220.     gInWord=TRUE;
  221.     StoreChar(ThisChar());
  222.     InputPlus(1);
  223. }
  224.